import {
  createRouter,
  createWebHistory,
  RouteRecordRaw,
  RouterOptions,
  Router,
  RouterHistory
} from "vue-router";
import { routes } from "./routes";

class RouterUtils {
  routes: Array<RouteRecordRaw>;

  constructor(routes: Array<RouteRecordRaw>) {
    this.routes = routes;
  }

  startCreateRouter(history: RouterHistory = createWebHistory()): Router {
    const options: RouterOptions = {
      history,
      routes: this.routes
    };
    return createRouter(options);
  }
}

export default new RouterUtils(routes).startCreateRouter();
